#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QHash>
#include "sqlquery.h"
#include "luaexecuter.h"
#include "peopletreemodel.h"
#include <QTreeWidgetItem>
#include "profile.h"
#include <QMdiSubWindow>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    
private slots:
    void execQuery();
    void execScript();
    void loadProfile(const QModelIndex &index);

protected:
    void closeEvent(QCloseEvent *e);

private:
    void initQSMenu(const QString &filename, const QString &jsonNode, QMenu *parentMenu, const char *member);
    void buildPeopleTree();

    Ui::MainWindow *ui;
    SqlQuery *m_sqlQuery;
    LuaExecuter *m_luaExecuter;
    QHash<int, QTreeWidgetItem*> m_treeGroups;
    QVector<QPluginLoader *> m_plugins;
    PeopleTreeModel *m_peopleTreeModel;
    Profile *m_profile;
    QMdiSubWindow *m_profileMdi;
};

#endif // MAINWINDOW_H
